import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import base from "./assets/utils/base";
import {
  Alert,
  Dialog,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Input,
  Radio,
  RadioGroup,
  Switch,
  Select,
  Option,
  Button,
  ButtonGroup,
  Table,
  TableColumn,
  DatePicker,
  TimeSelect,
  TimePicker,
  Form,
  FormItem,
  Icon,
  Col,
  Row,
  Pagination,
  Upload,
  Checkbox,
  Tooltip,
  Message,
  MessageBox,
  Loading,
  Notification,
  Steps,
  Step
} from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
// collapse 展开折叠
Vue.config.productionTip = false;
Vue.use(base);

Vue.use(Alert);
Vue.use(Dialog);
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Input);
Vue.use(Radio);
Vue.use(RadioGroup);
Vue.use(Switch);
Vue.use(Select);
Vue.use(Option);
Vue.use(Button);
Vue.use(ButtonGroup);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(DatePicker);
Vue.use(TimeSelect);
Vue.use(TimePicker);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Icon);
Vue.use(Row);
Vue.use(Pagination);
Vue.use(Upload);
Vue.use(Col);
Vue.use(Checkbox);
Vue.use(Tooltip);
Vue.use(Steps);
Vue.use(Step);
Vue.prototype.$alert = (msg, type, time) => {
  Message({
    duration: time || 5000,
    showClose: true,
    message: msg,
    type: type || "success"
  });
};
Vue.prototype.$loading = Loading.service;
Vue.prototype.$message = Message;

Vue.prototype.$notifyClose = Notification.closeAll;
Vue.prototype.$notify = (msg, option) => {
  let op = option || {};
  return Notification({
    title: op.title || "提示",
    showClose: op.showClose || true,
    message: msg,
    type: op.type || "info",
    customClass: op.customClass,
    position: op.position || "top-right",
    onClose: op.onClose,
    onClick: op.onClick,
    offset: op.offset,
    duration: op.duration || 0
  });
};
Vue.prototype.$confirm = (msg, option) => {
  let op = option || {};
  MessageBox({
    confirmButtonText: op.doneBtn || "确定",
    cancelButtonText: op.failBtn || "取消",
    showCancelButton: op.showFailBtn || false,
    type: op.type || "warning",
    title: op.title || "提示",
    message: msg,
    callback(action) {
      if (action === "confirm") {
        op.done && op.done();
      } else {
        op.fail && op.fail();
      }
    }
  });
};

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
